﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel.Syndication;
using System.Xml;
using System.Xml.Serialization;
using System.Web;
using System.Web.Services;

namespace PubSubHubbubWebCallback
{
	[WebService(Namespace = "http://www.badera.us/services/callbacks")]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	public class PushCallback : IHttpHandler
	{
		public void ProcessRequest(HttpContext context)
		{
			context.Response.ContentType = "text/plain";

			if ("GET" == context.Request.RequestType)
			{
				context.Response.Write(context.Request.QueryString["hub.challenge"]);
			}
			else if ("POST" == context.Request.RequestType)
			{
				using (XmlReader xmlReader = new XmlTextReader(context.Request.InputStream))
				{
					SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
				}
			}
		}

		public bool IsReusable
		{
			get
			{
				return true;
			}
		}
	}
}
